package casa.depesos.app.com.dlg;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import casa.depesos.app.com.databinding.DlgErrorBinding;

public class ErrDlg extends FullScreenDlg {
    DlgErrorBinding binding;

    String msg, ok;

    public ErrDlg setData(String msg, String ok) {
        this.msg = msg;
        this.ok = ok;
        return this;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DlgErrorBinding.inflate(inflater, container, false);
        if (!TextUtils.isEmpty(msg)) {
            binding.tv.setText(msg);
        }
        if (!TextUtils.isEmpty(ok)) {
            binding.btn.setText(ok);
        }
        binding.btn.setOnClickListener(view -> dismiss(true, null));
        return binding.getRoot();
    }
}
